<html>
<head><meta charset="utf-8"><title>Extract Module to File assist implementaion questions · t-compiler/rust-analyzer · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/index.html">t-compiler/rust-analyzer</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Extract.20Module.20to.20File.20assist.20implementaion.20questions.html">Extract Module to File assist implementaion questions</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="218827573"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Extract%20Module%20to%20File%20assist%20implementaion%20questions/near/218827573" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> sasurau4 <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Extract.20Module.20to.20File.20assist.20implementaion.20questions.html#218827573">(Dec 04 2020 at 12:44)</a>:</h4>
<p>I'll try to implement the assist to automate <a href="https://github.com/rust-analyzer/rust-analyzer/issues/6522">https://github.com/rust-analyzer/rust-analyzer/issues/6522</a> and then do the conversion. <br>
I have 2 questions to start it.</p>
<ol>
<li>Where is good to implement the assist? Inside test-util crate or create new one?</li>
<li>Is there good example implementation or package to achieve it?</li>
</ol>



<a name="218828207"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Extract%20Module%20to%20File%20assist%20implementaion%20questions/near/218828207" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Extract.20Module.20to.20File.20assist.20implementaion.20questions.html#218828207">(Dec 04 2020 at 12:51)</a>:</h4>
<p>Assists go into the <code>assists/src/handlers</code> directory</p>



<a name="218828218"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Extract%20Module%20to%20File%20assist%20implementaion%20questions/near/218828218" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Extract.20Module.20to.20File.20assist.20implementaion.20questions.html#218828218">(Dec 04 2020 at 12:51)</a>:</h4>
<p><a href="https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/assists/src/handlers/unwrap_block.rs">https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/assists/src/handlers/unwrap_block.rs</a> might be a good example</p>



<a name="218828755"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Extract%20Module%20to%20File%20assist%20implementaion%20questions/near/218828755" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> sasurau4 <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Extract.20Module.20to.20File.20assist.20implementaion.20questions.html#218828755">(Dec 04 2020 at 12:57)</a>:</h4>
<p>Thanks <span aria-label="thumbs up" class="emoji emoji-1f44d" role="img" title="thumbs up">:thumbs_up:</span></p>



<a name="218838153"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Extract%20Module%20to%20File%20assist%20implementaion%20questions/near/218838153" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> sasurau4 <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Extract.20Module.20to.20File.20assist.20implementaion.20questions.html#218838153">(Dec 04 2020 at 14:22)</a>:</h4>
<p>Does Rustdoc support multi-file code block like <a href="https://github.com/rust-analyzer/rust-analyzer/pull/6509">multi-file assist tests</a>?</p>
<div class="codehilite"><pre><span></span><code>// ```
//- /foo.rs
// mod tests {&lt;|&gt;
//     #[test] fn t() {}
// }
// ```
// -&gt;
// ```
//- /foo.rs
// mod tests;
//
//- /foo/tests.rs
// #[test] fn t() {}
// ```
</code></pre></div>



<a name="218838275"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Extract%20Module%20to%20File%20assist%20implementaion%20questions/near/218838275" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Extract.20Module.20to.20File.20assist.20implementaion.20questions.html#218838275">(Dec 04 2020 at 14:23)</a>:</h4>
<p>Probably not</p>



<a name="218839726"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Extract%20Module%20to%20File%20assist%20implementaion%20questions/near/218839726" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Extract.20Module.20to.20File.20assist.20implementaion.20questions.html#218839726">(Dec 04 2020 at 14:35)</a>:</h4>
<p>it does not</p>



<a name="219076358"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Extract%20Module%20to%20File%20assist%20implementaion%20questions/near/219076358" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> sasurau4 <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Extract.20Module.20to.20File.20assist.20implementaion.20questions.html#219076358">(Dec 07 2020 at 13:01)</a>:</h4>
<p>I tried to implement, but faced with <code>no value set for FileTextQuery(FileId(1))</code> when I use following as input for check_assist func.</p>
<div class="codehilite"><pre><span></span><code>   check_assist(
       extract_module_to_file,
       r#&quot;
//- /foo.rs crate:foo
mod tests {&lt;|&gt;
    #[test] fn t() {}
}
&quot;#,
       r#&quot;
//- /foo.rs crate:foo
mod tests;
//- /foo/tests.rs
#[test] fn t() {}
&quot;#,
   )
</code></pre></div>
<p>I think the the reason why this error is CreateFile doesn't update SourceRoot registered in SourceDatabaseExt in check func.<br>
How to update SourceRoot with file creation?</p>



<a name="219079028"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Extract%20Module%20to%20File%20assist%20implementaion%20questions/near/219079028" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Extract.20Module.20to.20File.20assist.20implementaion.20questions.html#219079028">(Dec 07 2020 at 13:28)</a>:</h4>
<p>I don't think we need to actively <em>update</em> anything when checking assists</p>



<a name="219079039"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Extract%20Module%20to%20File%20assist%20implementaion%20questions/near/219079039" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Extract.20Module.20to.20File.20assist.20implementaion.20questions.html#219079039">(Dec 07 2020 at 13:28)</a>:</h4>
<p>Rather, somewhere around this line: <a href="https://github.com/rust-analyzer/rust-analyzer/blob/403ed489ff51e4b1d9b1bbde1ddb6f765ebcbd1f/crates/assists/src/tests.rs#L106">https://github.com/rust-analyzer/rust-analyzer/blob/403ed489ff51e4b1d9b1bbde1ddb6f765ebcbd1f/crates/assists/src/tests.rs#L106</a></p>



<a name="219079082"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Extract%20Module%20to%20File%20assist%20implementaion%20questions/near/219079082" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Extract.20Module.20to.20File.20assist.20implementaion.20questions.html#219079082">(Dec 07 2020 at 13:28)</a>:</h4>
<p>We should take a look at <code>file_system_edits</code> and use them to see if the expected resut makes sense</p>



<a name="219087894"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Extract%20Module%20to%20File%20assist%20implementaion%20questions/near/219087894" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> sasurau4 <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Extract.20Module.20to.20File.20assist.20implementaion.20questions.html#219087894">(Dec 07 2020 at 14:44)</a>:</h4>
<p>I see. I'll try it <span aria-label="thumbs up" class="emoji emoji-1f44d" role="img" title="thumbs up">:thumbs_up:</span></p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>